package com.ankang.art.service.impl;

import com.ankang.art.dto.ExaminationDto;
import com.ankang.art.dto.addStudentToExamTestDto;
import com.ankang.art.mapper.ExaminationMapper;
import com.ankang.art.pto.ExaminationPto;
import com.ankang.art.service.ExaminationService;
import com.ankang.art.vo.Examination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author:
 * Date:2020/3/17    20:43
 */
@Service
public class ExaminationServiceImpl implements ExaminationService {

    @Autowired
    ExaminationMapper examinationMapper;

    @Override
    public void deleteExamination(String name) {
        examinationMapper.deleteExamination(name);
    }

    @Override
    public List<Examination> getExamination(String name, String status, Long beginTime, Long endTime) {
        return examinationMapper.getExamination(name, status, beginTime, endTime);
    }

    @Override
    public void updateExamination(ExaminationDto examinationDto) {
        examinationMapper.updateExamination(examinationDto);
    }

    @Override
    public void savaExamination(ExaminationPto examinationPto) {
        examinationMapper.savaExamination(examinationPto);
    }


    @Override
    public Boolean addStudentToExamTest(addStudentToExamTestDto addStudentToExamTestDto) {

        Integer testId = addStudentToExamTestDto.getTestId();
        for (Integer i = 0; i < addStudentToExamTestDto.getIds().size() ; i++) {
            List studentIdlist = addStudentToExamTestDto.getIds();
            Object studentId = studentIdlist.get(i);
            examinationMapper.addStudentToExamTest(studentId,testId);

        }
        return true;
    }
}
